<?php echo $form->renderFormTag('#', array('id' => 'form', 'method' => "post", "class" => "form")) ?>
<?= $form->renderHiddenFields() ?>
<fieldset>
    <div class="widget">
        <div class="title"> <?= image_tag('icons/color/plus.png', array("class" => "titleIcon")); ?><h6>Edit Invoice</h6></div>
        <div class="fluid">

            <div class="formRow">
                <label>Invoice Number:</label>
                <div class="formRight">
                    <span class="span6"><?php echo $form['invoice_code']->render(); ?> </span>
                    <span class="span6"><label for="invoice_code" generated="true" class="error"><?= $form['invoice_code']->renderError(); ?></label></span>
                </div>
            </div>

            <div class="formRow">
                <label>Customer:</label>
                <div class="formRight">
                    <span class="span6"><?php echo $form['customer_id']->render(array('data-placeholder' => " - - Select - - ", 'style' => "width:100%;", 'class' => "chzn-select")); ?> </span>
                    <span class="span6"><label for="customer_id" generated="true" class="error"><?= $form['customer_id']->renderError(); ?></label></span>
                </div>
            </div>

            <div class="formRow">
                <label>Line:</label>
                <div class="formRight">
                    <span class="span6"><?php echo $form['line_id']->render(array('data-placeholder' => " - - Select - - ", 'style' => "width:100%;", 'class' => "chzn-select")); ?> </span>
                    <span class="span6"><label for="line_id" generated="true" class="error"><?= $form['line_id']->renderError(); ?></label></span>
                </div>
            </div>

            <div class="formRow">
                <label>Items:<br><div class="addItem">Add Item</div></label>
                <?php for ($i = 1; $i < $count+1; $i++): ?>
                    <div class="parentShowDelete">
                        <div class="formRight " style="position: relative;">
                            <span class="span3"><span class="formNote">Product</span><?php echo $form['product_id_' . $i]->render(array('data-placeholder' => " - - Select - - ", 'style' => "width:100%;", 'class' => "chzn-select")); ?> </span>
                            <span class="span3"><span class="formNote">Unit</span><?php echo $form['unit_id_' . $i]->render(array('data-placeholder' => " - - Select - - ", 'style' => "width:100%;", 'class' => "chzn-select")); ?> </span>
                            <span class="span3"><span class="formNote">Price</span><?php echo $form['price_' . $i]->render(); ?> </span>
                            <span class="span3"><span class="formNote">quantity</span><?php echo $form['qty_' . $i]->render(); ?> </span>
                        <?php if($count > 1):?><div class="showDeleteIcon" onClick="deleteItem(this)"></div> <?php endif; ?>
                        </div>
                        <div class="formRight ">
                            <span class="span3"><label for="product_id" generated="true" class="error"><?= $form['product_id_' . $i]->renderError(); ?></label></span>
                            <span class="span3"><label for="unit_id" generated="true" class="error"><?= $form['unit_id_' . $i]->renderError(); ?></label></span>
                            <span class="span3"><label for="price" generated="true" class="error"><?= $form['price_' . $i]->renderError(); ?></label></span>
                            <span class="span3"><label for="qty" generated="true" class="error"><?= $form['qty_' . $i]->renderError(); ?></label></span>
                        </div>
                    </div>
                <?php endfor; ?>
            </div>


            <div class="formRow">
                <label>Date:</label>
                <div class="formRight">
                    <span class="span6"><?php echo $form['date']->render(array('class' => 'datepicker','readonly'=>'readonly')); ?> </span>
                    <span class="span6"><label for="date" generated="true" class="error"><?= $form['date']->renderError(); ?></label></span>
                </div>
            </div>
         
            
            <div class="formRow">
                <label>Discount:</label>
                <div class="formRight">
                    <span class="span3"> <?php echo $form['discount_type']->render(array('data-placeholder' => " - - Select - - ", 'style' => "width:100%;", 'class' => "chzn-select")); ?></span>
                    <span class="span3" style="width: 8%;margin-left: 3%;"><?php echo $form['discount']->render(); ?></span>
                    <span class="span3"><label for="date" generated="true" class="error"><?= $form['discount']->renderError(); ?></label></span>
                </div>
            </div>

            <div class="formRow">
                <label>Total Amount:</label>
                <div class="formRight">
                    <h2><span class="invoiceAmount"> 0.00 L.E</span></h2>
                </div>
            </div>


            <div class="wizButtons"> 
                <span class="wNavButtons">
                    <a class="wButton greenwB ml15 m10" title="" onClick="editInvoice(true,false,<?= $invoiceCode ?>)" href="javascript:void(0);"><span> S u b m i t </span></a>
                </span>
            </div>
        </div>


    </div>
</fieldset>
</form>

<div class="hiddenItems" style="display: none;">
    <div class="parentShowDelete">
        <div class="formRight" style="position: relative;">
            <span class="span3"><span class="formNote">Product</span><?php echo $form['product_id_0']->render(array('data-placeholder' => " - - Select - - ", 'style' => "width:100%;", 'class' => "")); ?> </span>
            <span class="span3"><span class="formNote">Unit</span><?php echo $form['unit_id_0']->render(array('data-placeholder' => " - - Select - - ", 'style' => "width:100%;", 'class' => "")); ?> </span>
            <span class="span3"><span class="formNote">Price</span><?php echo $form['price_0']->render(); ?> </span>
            <span class="span3"><span class="formNote">quantity</span><?php echo $form['qty_0']->render(); ?> </span>
            <div class="showDeleteIcon" onClick="deleteItem(this)"></div>
        </div>
    </div>
</div>